home *** CD-ROM | disk | FTP | other *** search
/ Erotic Games: Memory / Erotic Games: Memory.iso / mac / air_installers / AdobeAIR.exe / setup.swf / scripts / mx / states / SetStyle.as < prev    next >
Text File  |  2009-02-12  |  3KB  |  128 lines

  1. package mx.states
  2. {
  3.    import mx.core.UIComponent;
  4.    import mx.core.mx_internal;
  5.    import mx.styles.IStyleClient;
  6.    import mx.styles.StyleManager;
  7.    
  8.    use namespace mx_internal;
  9.    
  10.    public class SetStyle implements IOverride
  11.    {
  12.       
  13.       mx_internal static const VERSION:String = "3.0.0.0";
  14.       
  15.       private static const RELATED_PROPERTIES:Object = {
  16.          "left":["x"],
  17.          "top":["y"],
  18.          "right":["x"],
  19.          "bottom":["y"]
  20.       };
  21.        
  22.       
  23.       private var oldRelatedValues:Array;
  24.       
  25.       private var oldValue:Object;
  26.       
  27.       public var name:String;
  28.       
  29.       public var target:IStyleClient;
  30.       
  31.       public var value:Object;
  32.       
  33.       public function SetStyle(param1:IStyleClient = null, param2:String = null, param3:Object = null)
  34.       {
  35.          super();
  36.          this.target = param1;
  37.          this.name = param2;
  38.          this.value = param3;
  39.       }
  40.       
  41.       public function remove(param1:UIComponent) : void
  42.       {
  43.          var _loc4_:int = 0;
  44.          var _loc2_:IStyleClient = !!target ? target : param1;
  45.          if(oldValue is Number)
  46.          {
  47.             _loc2_.setStyle(name,Number(oldValue));
  48.          }
  49.          else if(oldValue is Boolean)
  50.          {
  51.             _loc2_.setStyle(name,toBoolean(oldValue));
  52.          }
  53.          else if(oldValue === null)
  54.          {
  55.             _loc2_.clearStyle(name);
  56.          }
  57.          else
  58.          {
  59.             _loc2_.setStyle(name,oldValue);
  60.          }
  61.          var _loc3_:Array = !!RELATED_PROPERTIES[name] ? RELATED_PROPERTIES[name] : null;
  62.          if(_loc3_)
  63.          {
  64.             _loc4_ = 0;
  65.             while(_loc4_ < _loc3_.length)
  66.             {
  67.                _loc2_[_loc3_[_loc4_]] = oldRelatedValues[_loc4_];
  68.                _loc4_++;
  69.             }
  70.          }
  71.       }
  72.       
  73.       private function toBoolean(param1:Object) : Boolean
  74.       {
  75.          if(param1 is String)
  76.          {
  77.             return param1.toLowerCase() == "true";
  78.          }
  79.          return param1 != false;
  80.       }
  81.       
  82.       public function apply(param1:UIComponent) : void
  83.       {
  84.          var _loc4_:int = 0;
  85.          var _loc2_:IStyleClient = !!target ? target : param1;
  86.          var _loc3_:Array = !!RELATED_PROPERTIES[name] ? RELATED_PROPERTIES[name] : null;
  87.          oldValue = _loc2_.getStyle(name);
  88.          if(_loc3_)
  89.          {
  90.             oldRelatedValues = [];
  91.             _loc4_ = 0;
  92.             while(_loc4_ < _loc3_.length)
  93.             {
  94.                oldRelatedValues[_loc4_] = _loc2_[_loc3_[_loc4_]];
  95.                _loc4_++;
  96.             }
  97.          }
  98.          if(value === null)
  99.          {
  100.             _loc2_.clearStyle(name);
  101.          }
  102.          else if(oldValue is Number)
  103.          {
  104.             if(name.toLowerCase().indexOf("color") != -1)
  105.             {
  106.                _loc2_.setStyle(name,StyleManager.getColorName(value));
  107.             }
  108.             else
  109.             {
  110.                _loc2_.setStyle(name,Number(value));
  111.             }
  112.          }
  113.          else if(oldValue is Boolean)
  114.          {
  115.             _loc2_.setStyle(name,toBoolean(value));
  116.          }
  117.          else
  118.          {
  119.             _loc2_.setStyle(name,value);
  120.          }
  121.       }
  122.       
  123.       public function initialize() : void
  124.       {
  125.       }
  126.    }
  127. }
  128.